package com.kanshu.ksgb.fastread.doudou.module.bookcity.adapter;

import android.content.Context;

import com.dl7.recycler.adapter.BaseQuickAdapter;
import com.dl7.recycler.adapter.BaseViewHolder;
import com.kanshu.ksgb.fastread.doudou.R;
import com.kanshu.ksgb.fastread.doudou.app.constants.ARouterConfig;
import com.kanshu.ksgb.fastread.doudou.common.imageloader.GlideImageLoader;
import com.kanshu.ksgb.fastread.doudou.common.util.ARouterUtils;
import com.kanshu.ksgb.fastread.doudou.common.business.commonbean.BookInfo;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 热门分类适配器
 * Created by wcy on 18/5/23.
 */
public class HotCategoryAdapter extends BaseQuickAdapter<BookInfo> {
    private int mSite;
    public HotCategoryAdapter(Context context, List<BookInfo> data, int site) {
        super(context, data);
        mSite = site;
    }

    @Override
    protected int attachLayoutRes() {
        return R.layout.item_ad_selected_hotcategory_item_layout;
    }

    @Override
    protected void convert(BaseViewHolder holder, BookInfo item, int position) {
        GlideImageLoader.load(item.img_url, holder.getView(R.id.cover));
        holder.getConvertView().setOnClickListener(v -> {
            Map<String, String> map = new HashMap<>();
            map.put("title", item.title);
            map.put("category_id_1", "");
            map.put("category_id_2", item.category);
            map.put("site", String.valueOf(mSite));
            ARouterUtils.toActivity(ARouterConfig.SUB_CATEGORY_LIST, map);
        });
    }
}
